import React from 'react'
import './SurveyDetail.css'

function SurveyDetail({ survey, onEdit, onBack }) {
  if (!survey) {
    return <div className="empty">未找到问卷信息</div>
  }

  return (
    <div className="survey-detail-container">
      <div className="detail-header">
        <h2>问卷详情</h2>
        <div className="header-actions">
          <button className="btn btn-warning" onClick={onEdit}>
            编辑
          </button>
          <button className="btn btn-secondary" onClick={onBack}>
            返回列表
          </button>
        </div>
      </div>

      <div className="detail-content">
        <div className="detail-item">
          <div className="item-label">公司名称</div>
          <div className="item-value">{survey.company_name}</div>
        </div>

        <div className="detail-item">
          <div className="item-label">姓名</div>
          <div className="item-value">{survey.name}</div>
        </div>

        <div className="detail-item">
          <div className="item-label">电话</div>
          <div className="item-value">{survey.phone}</div>
        </div>

        <div className="detail-item">
          <div className="item-label">地址</div>
          <div className="item-value">{survey.address}</div>
        </div>

        <div className="detail-item">
          <div className="item-label">负责人</div>
          <div className="item-value">{survey.manager}</div>
        </div>

        <div className="detail-item">
          <div className="item-label">创建时间</div>
          <div className="item-value">
            {new Date(survey.created_at).toLocaleString('zh-CN')}
          </div>
        </div>

        <div className="detail-item">
          <div className="item-label">更新时间</div>
          <div className="item-value">
            {new Date(survey.updated_at).toLocaleString('zh-CN')}
          </div>
        </div>
      </div>
    </div>
  )
}

export default SurveyDetail
